<?php
use \Roboframe\ActiveRecord\Model;
class RolePermission extends Model {
  static $belongs_to = array(
    array('role')
   ,array('permission') 
  );
  
  static $validates_presence_of = array(
    array('role_id')
   ,array('permission_id')
  );
  
  public static function delete_all_by_role_id($role_id) {
    $rps = static::find('all', array('conditions' => array('role_id = ?', $role_id)));
    foreach($rps as $rp)  {
      $rp->delete();
    }
  }
}